package com.xls.box2023.jinbi;

import com.lzz.bottomencapsulation.net.RequestCallBack;
import com.lzz.bottomencapsulation.net.RetrofitBase;
import com.lzz.bottomencapsulation.utils.AppUtils;
import com.xls.box2023.BoxAppLication;
import com.xls.box2023.entity.AppsRulesEntity;
import com.xls.box2023.entity.JiFenDuiHuanJiLuEntity;
import com.xls.box2023.entity.JiFenMingXiEntity;
import com.xls.box2023.entity.JiFenTiXianBiliEntity;
import com.xls.box2023.entity.PageEntity;
import com.xls.box2023.entity.TiXianJiLuEntity;
import com.xls.box2023.entity.UserEntity;
import com.xls.box2023.entity.YouXiXiaoHaoJinBiEntity;
import com.xls.box2023.network.RequestManager;
import com.xls.box2023.utils.SPUtils;

import java.util.ArrayList;

public class JinBiNetWorkUtil {
    /**
    * 单例模式
    **/
    private static JinBiNetWorkUtil mJinBiNetWorkUtil = null;
        /**
         * 构造函数私有化
         **/
        private JinBiNetWorkUtil() {
        }
        /**
         * 公有的静态函数，对外暴露获取单例对象的接口
         **/
        public static JinBiNetWorkUtil getInstance() {
            if (mJinBiNetWorkUtil == null) {
                synchronized (JinBiNetWorkUtil.class) {
                    if (mJinBiNetWorkUtil == null) {
                        mJinBiNetWorkUtil = new JinBiNetWorkUtil();
                    }
                }
            }
            return mJinBiNetWorkUtil;
        }


    public void getMyDownLoadAppRecords(int pageSize, int pageNum, RequestCallBack<PageEntity<YouXiXiaoHaoJinBiEntity>> callBack) {
        RetrofitBase.getInstace(BoxAppLication.getBaseApplication()).setSubscribe(BoxAppLication.getBaseApplication(), RequestManager.getInstance(BoxAppLication.getBaseApplication()).
                getMyDownLoadAppRecords(pageSize, pageNum),callBack);
    }

    /**
     * 获取积分兑换金币得明细
     * @param pageSize
     * @param pageNum
     * @param appId
     * @param callBack
     */
    public void getMyScoreExchangeRecords(String typeId,int pageSize, int pageNum, String appId, RequestCallBack<PageEntity<JiFenDuiHuanJiLuEntity>> callBack) {
        RetrofitBase.getInstace(BoxAppLication.getBaseApplication()).setSubscribe(BoxAppLication.getBaseApplication(), RequestManager.getInstance(BoxAppLication.getBaseApplication()).
                getMyScoreExchangeRecords(pageSize, pageNum,appId,typeId),callBack);
    }

    public void getMyCoinsExchangeRecords(int pageSize, int pageNum, RequestCallBack<PageEntity<TiXianJiLuEntity>> callBack) {
        RetrofitBase.getInstace(BoxAppLication.getBaseApplication()).setSubscribe(BoxAppLication.getBaseApplication(), RequestManager.getInstance(BoxAppLication.getBaseApplication()).
                getMyCoinsExchangeRecords(pageSize, pageNum),callBack);

    }

    public void coinsExchange(String numStr,RequestCallBack<String> callBack) {
        UserEntity userEntity=(UserEntity) SPUtils.getUserInfo();
        RetrofitBase.getInstace(BoxAppLication.getBaseApplication()).setSubscribe(BoxAppLication.getBaseApplication(), RequestManager.getInstance(BoxAppLication.getBaseApplication()).
                coinsExchange(numStr,userEntity.getUnionId(),SPUtils.getOpenId(),userEntity.getAvatar(),userEntity.getNickname(), AppUtils.getPackageName(BoxAppLication.getBaseApplication()),1+""),callBack);
    }

    /**
     * 获取提现额度tab
     * @param appId
     * @param callBack
     */
    public void getAppRules(String appId,String packageName,String type,RequestCallBack<ArrayList<AppsRulesEntity>> callBack) {
        RetrofitBase.getInstace(BoxAppLication.getBaseApplication()).setSubscribe(BoxAppLication.getBaseApplication(), RequestManager.getInstance(BoxAppLication.getBaseApplication()).
                getAppRules(appId,packageName,type),callBack);
    }

    public void getUserLevel(String appId , String packageName, RequestCallBack<UserEntity> callBack) {
        RetrofitBase.getInstace(BoxAppLication.getBaseApplication()).setSubscribe(BoxAppLication.getBaseApplication(), RequestManager.getInstance(BoxAppLication.getBaseApplication()).
                getUserLevel(appId,packageName),callBack);
    }

    public void getScoreExchangeRateRules(String appId,String packageName, RequestCallBack<ArrayList<JiFenTiXianBiliEntity>> callBack) {
        RetrofitBase.getInstace(BoxAppLication.getBaseApplication()).setSubscribe(BoxAppLication.getBaseApplication(), RequestManager.getInstance(BoxAppLication.getBaseApplication()).
                getScoreExchangeRateRules(appId,packageName),callBack);
    }

    /**
     * 获取游戏积分数据
     * @param appId
     * @param packageName
     * @param callBack
     */
    public void getAccountByAppId(String appId, String packageName, RequestCallBack<JiFenMingXiEntity> callBack) {
        RetrofitBase.getInstace(BoxAppLication.getBaseApplication()).setSubscribe(BoxAppLication.getBaseApplication(), RequestManager.getInstance(BoxAppLication.getBaseApplication()).
                getAccountByAppId(appId,packageName),callBack);
    }
}
